package com.taxigang.client.uibinder;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.taxigang.shared.TaxiCompanyInfo;

public class TaxiCompanyDialog {
	/**
	 * Initialize this example.
	 */
	/**
	 * Create the dialog box for this example.
	 *
	 * @return the new dialog box
	 */
	final static DialogBox dialogBox1 = new DialogBox(false,true);

	public static void show(final TaxiCompanyInfo taxiCompanyInfo, final Command cmd) {
		// Create a dialog box and set the caption text

		dialogBox1.setHTML("<p><b>"+"order a taxi"+"</b></p>");

		//Window.alert(dialogBox.getHTML());

		// Create a table to layout the content
		VerticalPanel dialogContents = new VerticalPanel();
		dialogContents.setSpacing(4);
		dialogBox1.setWidget(dialogContents);

		TaxiCompanyDetail detail = new TaxiCompanyDetail();
		detail.set(taxiCompanyInfo);
		dialogContents.add(detail);
		dialogContents.setCellHorizontalAlignment(
				detail, HasHorizontalAlignment.ALIGN_CENTER);



		// Return the dialog box
		dialogBox1.setGlassEnabled(true);
		dialogBox1.setAnimationEnabled(true);

		dialogBox1.center();
		dialogBox1.show();
		
		detail.getConfirmButton().addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				
				cmd.execute();
				hide();

			}
		});
		detail.getCancelButton().addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				hide();
			}
		});
	}

	public static void hide(){
		dialogBox1.hide();

	}
}


